from django.db import models

from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
    phone = models.CharField(max_length=11)
    type = models.IntegerField(choices=((1, "普通用户"), (2, "VIP用户"), (3, "SVIP用户")), default=1)


class Token(models.Model):
    key = models.CharField(max_length=32)
    user = models.OneToOneField(User, on_delete=True)
    created = models.DateTimeField(auto_now_add=True)


class Code(models.Model):
    code = models.CharField(max_length=6)
    phone = models.CharField(max_length=11)
    created = models.DateTimeField(auto_now_add=True)


class Book(models.Model):
    name = models.CharField(max_length=11)
    author = models.CharField(max_length=10)
    click = models.IntegerField()
    count = models.IntegerField()


class Hero(models.Model):
    name = models.CharField(max_length=10)
    books = models.ForeignKey(Book, on_delete=True)
    age=models.IntegerField()


